<?php
include('modul/general.php');
global $mode,$DisBuku,$DisBayar,$DisLapor,$Ddivisi,$DLWilayah;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Accounting &amp; Finance System PT Nindya Karya</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
BODY {
	SCROLLBAR-FACE-COLOR: #95BCDB; SCROLLBAR-HIGHLIGHT-COLOR: #ffffff; SCROLLBAR-SHADOW-COLOR: #1A72BC; COLOR: #000000; SCROLLBAR-ARROW-COLOR: #000000; SCROLLBAR-BASE-COLOR: #BDDBF2; scrollbar-3d-light-color: #CADAF7; scrollbar-dark-shadow-color: #CADAF7
}
A:link {
	COLOR: #336699; TEXT-DECORATION: none
}
A:visited {
	COLOR: #336699; TEXT-DECORATION: none
}
A:hover {
	COLOR: #ff0000; TEXT-DECORATION: none
}
</style>
<script type="text/javascript">
    function detailFaktur(object){
        var arrhp='';
        var width = (screen.width - 150);
        var height = (screen.height - 200);
        var left = (screen.width - width)/2;
        var top = (screen.height - height)/2;
        NAME = "DETAIL FAKTUR PAJAK";
        OPTIONS = "width="+width+",height="+height+",screenX=500,toolbars=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable='no',top="+top+",left="+left+"";

        var windowsms2 = window.open("fakturpajak/detail-faktur.php?"+object, NAME, OPTIONS);
    }
</script>
</head>
<body leftmargin="0" topmargin="0">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="80%" valign="top">
      <?if($cdivisi_kode=='KP'){?>
        <br>
      <table width="100%" border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#FFFFFF'>
        <tr>
          <td height="20" background="gambar/bg-menu.gif" colspan="7"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="32"><img src="gambar/menu-kiri.gif" width="32" height="20"></td>
                <td><div align="center"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>DAFTAR FAKTUR PAJAK PER WILAYAH</strong></font></div></td>
                <td width="32"><img src="gambar/menu-kanan.gif" width="32" height="20"></td>
              </tr>
            </table></td>
        </tr>
        <tr bgcolor='#1A75BF'>
          <th height="25"><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>NO</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Kode Wilayah</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Nama Wilayah</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jml Belum Di Bukukan</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jml Belum Di Bayarkan</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jml Belum Di Laporkan</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jumlah Faktur</strong></font></th>
        </tr>
        <?php
        $warna = "#FFFFFF";
        $no = 0;
        $rsq = getRSq("SELECT DISTINCT divisi_kode FROM tbl_spt ORDER BY divisi_kode ASC");
//        $rs1 = getRS("SELECT DISTINCT divisi_kode FROM tbl_spt ORDER BY divisi_kode ASC");
//        $divisi_wilayah1 = explode(".",$rs1['divisi_kode']);
//        $divisi_len1 = strlen($divisi_wilayah1[0]);
//        $rsq = getRSq("SELECT DISTINCT substr(divisi_kode,1,$divisi_len1) as divisi_kode FROM tbl_spt WHERE divisi_kode like '%$divisi_wilayah1[0]%'");
//        echo "SELECT DISTINCT substr(divisi_kode,1,$divisi_len1) FROM tbl_spt WHERE divisi_kode like '%$divisi_wilayah1[0]%'";
        while ($rs = pg_fetch_array($rsq)){
            
            $divisi_wilayah = explode(".",$rs['divisi_kode']);
            $divisi_len = strlen($divisi_wilayah[0]);
            $rs1 = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE substr(divisi_kode,1,$divisi_len)='".$divisi_wilayah[0]."'");
            $rs1buku = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE substr(divisi_kode,1,$divisi_len)='".$divisi_wilayah[0]."' AND (is_buku='N')");
            $rs1bayar = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE substr(divisi_kode,1,$divisi_len)='".$divisi_wilayah[0]."' AND (is_bayar='N')");
            $rs1lapor = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE substr(divisi_kode,1,$divisi_len)='".$divisi_wilayah[0]."' AND (is_lapor='N')");
//            $rs1bukubayar = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE substr(divisi_kode,1,$divisi_len)='".$divisi_wilayah[0]."' AND (is_buku='N' AND is_bayar='N')");
            $rs1divisi = getRS("SELECT divisi_name FROM tbl_divisi WHERE divisi_kode='".$divisi_wilayah[0]."'");
            
            if ($warna="#FFFFFF"){
                $warna = "#d0ebf6";
            }else{
                $warna="#FFFFFF";
            }
            if ($rs['divisi_kode']==$divisi_wilayah[0]){
            $no++;
        ?>
        <tr bgcolor="<?=$warna?>">
          <td align="center" height="25"><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$no ?></font></td>
          <td align="center"><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$divisi_wilayah[0] ?></font></td>
          <td align="center"><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs1divisi['divisi_name'] ?></font></td>
          <td align="center"><a href=javascript:detailFaktur('DLWilayah=KP&DisBuku=N&Ddivisi=<?=$divisi_wilayah[0]?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs1buku['jml'] ?></font></a></td>
          <td align="center"><a href=javascript:detailFaktur('DLWilayah=KP&DisBayar=N&Ddivisi=<?=$divisi_wilayah[0]?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs1bayar['jml'] ?></font></a></td>
          <td align="center"><a href=javascript:detailFaktur('DLWilayah=KP&DisLapor=N&Ddivisi=<?=$divisi_wilayah[0]?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs1lapor['jml'] ?></font></a></td>
          <td align="center"><a href=javascript:detailFaktur('DLWilayah=KP&Ddivisi=<?=$divisi_wilayah[0]?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs1['jml'] ?></font></a></td>
        </tr>
        <?php } } ?>
      </table>
     <?//}else if($cdivisi_kode=='%%%'){?>

     <?}else{
         $divisi_wilayah1 = explode(".",$cdivisi_kode);
         if ($cdivisi_kode==$divisi_wilayah1[0]){
     ?>
      <br>
      <table width="100%" border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#FFFFFF'>
          <?php
            $divisi_wilayah = explode(".",$cdivisi_kode);
            $divisi_len = strlen($divisi_wilayah[0]);
            $rs1 = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE divisi_kode='".$divisi_wilayah[0]."'");
            $rs1buku = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE divisi_kode='".$divisi_wilayah[0]."' AND (is_buku='N')");
            $rs1bayar = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE divisi_kode='".$divisi_wilayah[0]."' AND (is_bayar='N')");
            $rs1lapor = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE divisi_kode='".$divisi_wilayah[0]."' AND (is_lapor='N')");
//            $rs1 = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE substr(divisi_kode,1,$divisi_len)='".$divisi_wilayah[0]."'");
//            $rs1buku = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE substr(divisi_kode,1,$divisi_len)='".$divisi_wilayah[0]."' AND (is_buku='N')");
//            $rs1bayar = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE substr(divisi_kode,1,$divisi_len)='".$divisi_wilayah[0]."' AND (is_bayar='N')");
//            $rs1lapor = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE substr(divisi_kode,1,$divisi_len)='".$divisi_wilayah[0]."' AND (is_lapor='N')");
            //$rs1bukubayar = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE substr(divisi_kode,1,$divisi_len)='".$divisi_wilayah[0]."' AND (is_buku='N' AND is_bayar='N')");
            $rs1divisi = getRS("SELECT divisi_name FROM tbl_divisi WHERE divisi_kode='".$divisi_wilayah[0]."'");
            $no = 1;
        ?>
        <tr>
          <td height="20" background="gambar/bg-menu.gif" colspan="7"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="32"><img src="gambar/menu-kiri.gif" width="32" height="20"></td>
                <td><div align="center"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>DAFTAR FAKTUR PAJAK <?=strtoupper($rs1divisi['divisi_name']) ?></strong></font></div></td>
                <td width="32"><img src="gambar/menu-kanan.gif" width="32" height="20"></td>
              </tr>
            </table></td>
        </tr>
        <tr bgcolor='#1A75BF'>
          <th height="25"><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>NO</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Kode Wilayah</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Nama Wilayah</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jml Belum Di Bukukan</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jml Belum Di Bayarkan</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jml Belum Di Laporkan</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jumlah Faktur</strong></font></th>
        </tr>
        
        <tr bgcolor="#d0ebf6">
          <td align="center" height="25"><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$no ?></font></td>
          <td align="center"><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$divisi_wilayah[0] ?></font></td>
          <td align="center"><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs1divisi['divisi_name'] ?></font></td>
          <td align="center"><a href=javascript:detailFaktur('DisBuku=N&Ddivisi=<?=$divisi_wilayah[0]?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs1buku['jml'] ?></font></a></td>
          <td align="center"><a href=javascript:detailFaktur('DisBayar=N&Ddivisi=<?=$divisi_wilayah[0]?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs1bayar['jml'] ?></font></a></td>
          <td align="center"><a href=javascript:detailFaktur('DisLapor=N&Ddivisi=<?=$divisi_wilayah[0]?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs1lapor['jml'] ?></font></a></td>
          <td align="center"><a href=javascript:detailFaktur('Ddivisi=<?=$divisi_wilayah[0]?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs1['jml'] ?></font></a></td>
        </tr>
      </table>
      <?php } ?>
      <br>
      <table width="100%" border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#FFFFFF'>
        <tr>
          <td height="20" background="gambar/bg-menu.gif" colspan="7"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="32"><img src="gambar/menu-kiri.gif" width="32" height="20"></td>
                <td><div align="center"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>DAFTAR FAKTUR PAJAK <?=strtoupper($rs1divisi['divisi_name'])?></strong></font></div></td>
                <td width="32"><img src="gambar/menu-kanan.gif" width="32" height="20"></td>
              </tr>
            </table></td>
        </tr>
        <tr bgcolor='#1A75BF'>
          <th height="25"><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>NO</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Kode Wilayah</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Nama Wilayah</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jml Belum Di Bukukan</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jml Belum Di Bayarkan</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jml Belum Di Laporkan</strong></font></th>
          <th><font color='#FFFFFF' size='1' face='Verdana, Arial, Helvetica, sans-serif'><strong>Jumlah Faktur</strong></font></th>
        </tr>
        <?php
        $warna1 = "#FFFFFF";
        $no1 = 0;
        $divisi_wilayah1 = explode(".",$cdivisi_kode);
        $divisi_wilayah1search = $divisi_wilayah1[0].".";
        $rsq1 = getRSq("SELECT DISTINCT divisi_kode FROM tbl_spt WHERE divisi_kode like '%$divisi_wilayah1[0].%' AND divisi_kode!='".$divisi_wilayah1[0]."' ORDER BY divisi_kode ASC");
        while ($rs1 = pg_fetch_array($rsq1)){
            $no1++;
            $rs11 = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE divisi_kode='".$rs1['divisi_kode']."'");
            $rs11buku = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE divisi_kode='".$rs1['divisi_kode']."' AND (is_buku='N')");
            $rs11bayar = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE divisi_kode='".$rs1['divisi_kode']."' AND (is_bayar='N')");
            $rs11lapor = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE divisi_kode='".$rs1['divisi_kode']."' AND (is_lapor='N')");
            //$rs11bukubayar = getRS("SELECT COUNT(*) as jml FROM tbl_spt WHERE divisi_kode='".$rs1['divisi_kode']."' AND (is_buku='N' AND is_bayar='N')");
            $rs11divisi = getRS("SELECT divisi_name FROM tbl_divisi WHERE divisi_kode='".$rs1['divisi_kode']."'");

            if ($warna1="#FFFFFF"){
                $warna1 = "#d0ebf6";
            }else{
                $warna1="#FFFFFF";
            }
        ?>
        <tr bgcolor="<?=$warna1?>">
          <td align="center" height="25"><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$no1 ?></font></td>
          <td align="center"><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs1['divisi_kode'] ?></font></td>
          <td align="center"><font size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs11divisi['divisi_name'] ?></font></td>
          <td align="center"><a href=javascript:detailFaktur('DisBuku=N&Ddivisi=<?=$rs1['divisi_kode']?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs11buku['jml'] ?></font></a></td>
          <td align="center"><a href=javascript:detailFaktur('DisBayar=N&Ddivisi=<?=$rs1['divisi_kode']?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs11bayar['jml'] ?></font></a></td>
          <td align="center"><a href=javascript:detailFaktur('DisLapor=N&Ddivisi=<?=$rs1['divisi_kode']?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs11lapor['jml'] ?></font></a></td>
          <td align="center"><a href=javascript:detailFaktur('Ddivisi=<?=$rs1['divisi_kode']?>')><font color="red" size='1' face='Verdana, Arial, Helvetica, sans-serif'><?=$rs11['jml'] ?></font></a></td>
        </tr>
        <?php } ?>
      </table>
	<?php }?>
    </td>
  </tr>
</table>
</body>
</html>
